/*******************************************************************************
 * Copyright (c) 2010, 2030 www.itlaobing.cn
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package cn.itlaobing.servlet;/**
 * Created by asus-pc on 2017/11/10 0010.
 */

import cn.itlaobing.annotation.RequestMapping;
import cn.itlaobing.dao.TrainDao;
import cn.itlaobing.model.TrainModel;

import com.sun.javafx.scene.control.skin.VirtualFlow;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * ClassName: StationServlet <br/>
 * Function: TODO 功能描述 <br/>
 * date: 2017/11/10 0010 10:05 <br/>
 *
 * @author SCAR、
 * @since JDK 1.8
 */
@WebServlet("/select/*")
public class StationServlet extends BaseServlet{
    @RequestMapping("/station")
    public void station(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
          request.setCharacterEncoding("utf-8");
        String  trainNum=request.getParameter("trainnum");
        String oneStation=request.getParameter("onestation");
        String otherStation=request.getParameter("otherstation");
        TrainDao td= new TrainDao();
        List<TrainModel> list=null;

        try {
            list = td.findTrain(trainNum,oneStation,otherStation);
        } catch (SQLException e) {
            e.printStackTrace();
        }



        request.setAttribute("list",list);
        request.getRequestDispatcher("/WEB-INF/views/show.jsp").forward(request,response);
//        toView(request,response,"/show");
    }
}
